package test2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.alibaba.excel.write.handler.WriteHandler;
import com.alibaba.excel.write.merge.LoopMergeStrategy;

import test2.pojo.Se;
import utils.WishColumn;
import utils.WishExcel;
import utils.handlers.FreezeWriteHandler;
import utils.handlers.LoopRowBoldWriteHandler;

// 单个sheet和单个数据源
public class Test
{
	public static List<Se> getDatas()
	{
		// 数据
		List<Se> datas = new ArrayList<>();
		Se a = new Se();
		a.setName("张三");
		a.setAge(18);
		datas.add(a);

		Se b = new Se();
		b.setName("李四");
		b.setAge(19);
		datas.add(b);

		Se c = new Se();
		c.setName("王五");
		c.setAge(19);
		datas.add(c);

		for (int i = 0; i < 11; i++)
		{
			Se se = new Se();
			se.setName("李" + i);
			se.setAge(19 + i);
			datas.add(se);
		}
		return datas;
	}

	public static void main(String[] args)
	{
		// 数据
		List<Se> datas = getDatas();
		// 头部
		// new TableHeader<>("姓名",60, Se::getName);

		WishColumn<Se> header1 = new WishColumn<>("姓名", 10, Se::getName);
		WishColumn<Se> header2 = new WishColumn<>("年龄", Se::getAge);
		WishColumn<Se> header3 = new WishColumn<>("固定列", 100, x -> "固定");
		// 导出

		LoopMergeStrategy l = new LoopMergeStrategy(2, 0);
		LoopMergeStrategy l1 = new LoopMergeStrategy(2, 1);

		List<WriteHandler> list = new ArrayList<>();
//		list.add(l);
//		list.add(l1);
		
//		OnceAbsoluteMergeStrategy c= new OnceAbsoluteMergeStrategy(0, 0, 0, 1);
//		list.add(c);

//		WriteHandler a = new RowBoldWriteHandler(13);
//		list.add(a);
		
		WriteHandler b = new LoopRowBoldWriteHandler(4);
		list.add(b);
		list.add(new FreezeWriteHandler());
		WishExcel.write("test.xlsx", Arrays.asList(new WishColumn<>("整体名称你分析", Arrays.asList(header1, header2, header3))), datas, list, "这是sheet名称");
	}
}
